// 统一管理会员中心模块接口
import requset from "@/utils/request";
// 引入ts类型
import { SubmitOrderResponseData, OrderInfoResponseData, qrcodeInfoResponseData, payResultResponseData, UseringoResponseData, CertificatesTypeResponseData, userAuahData, allOrderInfoResponseData, allUserResponseData, OrderStateResponseData, CityResponseData, AddOrUpdateUserData } from './type'
// 枚举
enum API {
    // 提交订单
    SUBMITORDER_URL = '/order/orderInfo/auth/submitOrder/',
    // 获取订单详情
    GETORDERINFO_URL = '/order/orderInfo/auth/getOrderInfo/',
    // 取消订单
    CANCELORDER_URL = '/order/orderInfo/auth/cancelOrder/',
    // 获取二维码
    GETQRCODE_URL = '/order/weixin/createNative/',
    // 获取支付状态
    PAYRESULT_URL = '/order/weixin/queryPayStatus/',
    // 获取用户信息
    GETUSERINFO_URL = '/user/auth/getUserInfo',
    // 获取证件类型
    CERTIFICATESTYPE_URL = '/cmn/dict/findByDictCode/',
    // 会员认证
    USERAUAH_URL = '/user/auth/userAuah',
    // 获取全部订单
    GETALLORDERINFO_URL = '/order/orderInfo/auth/',
    //获取全部就诊人的信息
    ALLUSER_URL = '/user/patient/auth/findAll',
    //获取订单的状态
    ORDERSTATE_URL = '/order/orderInfo/auth/getStatusList',
    // 获取城市
    GETCITY_URL = '/cmn/dict/findByParentId/',
    // 添加就诊人
    ADDUSER_URL = '/user/patient/auth/save',
    // 修改就诊人信息
    UPDATEUSER_URL = '/user/patient/auth/update',
    // 删除就诊人
    DELETEUSER_URL = '/user/patient/auth/remove/'
}
// 提交订单的接口
export const reqSubmitOrder = (hoscode: string, scheduleId: string, patientId: number) => requset.post<any, SubmitOrderResponseData>(API.SUBMITORDER_URL + `${hoscode}/${scheduleId}/${patientId}`)
// 获取订单详情的接口
export const reqOrderInfo = (id: string) => requset.get<any, OrderInfoResponseData>(API.GETORDERINFO_URL + id)
// 取消订单的接口
export const reqCancelOrder = (orderId:string) => requset.get<any,any>(API.CANCELORDER_URL + orderId)
// 获取二维码的接口
export const reqQrcode = (orderId: string) => requset.get<any, qrcodeInfoResponseData>(API.GETQRCODE_URL + orderId)
// 获取支付状态的接口
export const reqPayResult = (orderId: string) => requset.get<any, payResultResponseData>(API.PAYRESULT_URL + orderId)
// 获取用户信息的接口
export const reqUserInfo = () => requset.get<any, UseringoResponseData>(API.GETUSERINFO_URL)
// 获取证件类型的接口
export const reqCertificatesType = (CertificatesType = 'CertificatesType') => requset.get<any, CertificatesTypeResponseData>(API.CERTIFICATESTYPE_URL + CertificatesType)
// 会员认证的接口
export const reqUserAuah = (data: userAuahData) => requset.post<any,any>(API.USERAUAH_URL , data)
// 获取全部订单的接口
export const reqAllOrderInfo = (page: number, limit: number, patientId: string, orderStatus: string) => requset.get<any, allOrderInfoResponseData>(API.GETALLORDERINFO_URL + `${page}/${limit}?patientId=${patientId}&orderStatus=${orderStatus}`)
//获取全部就诊人的信息
export const reqAllUser = () => requset.get<any, allUserResponseData>(API.ALLUSER_URL);
//获取全部订单状态的接口
export const reqOrderState = () => requset.get<any, OrderStateResponseData>(API.ORDERSTATE_URL);
// 获取城市的接口
export const reqCity = (parentId: number) => requset.get<any, CityResponseData>(API.GETCITY_URL + parentId)
// 添加就诊人|修改就诊人的接口
export const reqAddOrUpdateUser = (data: AddOrUpdateUserData)=>{
    if(data.id){
        return requset.put<any,any>(API.UPDATEUSER_URL,data)
    }else{
        return requset.post<any,any>(API.ADDUSER_URL,data)
    }
}
// 删除就诊人的接口
export const reqDeleteUser = (id:string)=> requset.delete<any,any>(API.DELETEUSER_URL + id)